﻿using System;
using StateMachine.TextParsing;

namespace WpfClient.FunctionFileParsing
{
    public class FunctionsFileParser : TextParser<FunctionFileParsingState>
    {
        private readonly FunctionFileParserContext parsingContext;

        public FunctionsFileParser()
            : base(new FunctionFileParserContext(FunctionFileParsingState.Indifferent))
        {
            this.parsingContext = base.TextParserContext as FunctionFileParserContext;

            this.RegisterStateHandler(FunctionFileParsingState.Indifferent, new IndifferentStateHandler(this.ParsingContext));
            this.RegisterStateHandler(FunctionFileParsingState.FunctionName, new FunctionNameStateHandler(this.ParsingContext));
        }

        private FunctionFileParserContext ParsingContext
        {
            get
            {
                return this.parsingContext;
            }
        }

        public string Result
        {
            get
            {
                return this.ParsingContext.Result.GetResultFileContent();
            }
        }
    }
}
